package org.colcon.web.model;

import java.util.HashMap;
import java.util.Map;

import org.colcon.web.model.framework.ITitle;

public class Title extends Container implements ITitle
{
	public String getType(){return "title";}
	
	private static final long serialVersionUID = 5495690195691831364L;
	
	public static final String
	
		// link containers
		HOLDERS = "holders";
	
	protected static final String
	
		// arguments
		TEXT = "text",
		COUNT = "count";
	
	public Title()
	{
		this(new HashMap<String, String>());
	}
	
	public Title(Map<String, String> args)
	{
		this(
				args.get(PARENT), 
				args.get(ID), 
				args.get(TEXT), 
				args.get(COUNT), 
				args.get(CHILDREN)
			);
	}
	
	public Title(String parent, String id, String text, String count, String children)
	{
		super(parent, id, children);
		
		setArg(TEXT, text);
		setArg(COUNT, count);
	}
	
	public String getGroup()
	{
		return Group.pathToGroup(getParentPath());
	}
	
	public void setText(String text)
	{
		setArg(TEXT, text);
	}
	
	public int getCount()
	{
		return Integer.valueOf(getArg(COUNT));
	}
	
	public String getLongId()
	{
		return getId() + " of " + getGroup();
	}
	
	public String holders()
	{
		return getPath() + '/' +  "holders";
	}
	
	public static String pathToLongId(String path)
	{
		return Item.pathToId(path) + " of " + Group.pathToGroup(path);
	}
}
